package com.shhm.admin.controller;

import com.shhm.admin.service.RoleOperatePermsService;
import com.shhm.common.annotations.OperateLog;
import com.shhm.common.dto.request.RequestList;
import com.shhm.common.dto.request.admin.RolePermsReq;
import com.shhm.common.dto.request.admin.SysUserRoleReq;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.dto.response.admin.SysRoleOperatePermsVO;
import com.shhm.common.dto.response.admin.SysUserRoleVO;
import com.shhm.common.entity.admin.SysRoleOperatePerms;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.*;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/8/15 下午2:33
 */
@RestController
@RequestMapping("/admin")
public class RoleOperatePermsController {
    @Resource
    private RoleOperatePermsService roleOperatePermsService;
    
    @GetMapping("/rop")
    public AjaxResultPlus pageList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            HttpServletRequest request
    ){
        return roleOperatePermsService.pageList(pageNum,pageSize,request);
    }

    @PostMapping("/rop/search")
    public AjaxResultPlus pageSearchList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody SysRoleOperatePermsVO entity
    ){
        System.out.println(entity.toString());
        return roleOperatePermsService.pageSearchList(pageNum,pageSize,entity);
    }

    /**
     * 废弃
     * @param entity
     * @return
     */
//    @PostMapping("/rop")
    @OperateLog(module="角色操作权限管理",type = "POST",desc = "添加系统角色操作权限信息")
    public AjaxResultPlus addfq(@RequestBody SysRoleOperatePerms entity){
        return roleOperatePermsService.add(entity);
    }

    @PutMapping("/rop")
    @OperateLog(module="角色操作权限管理",type = "PUT",desc = "修改系统角色操作权限信息")
    public AjaxResultPlus updatefq(@RequestBody SysRoleOperatePerms entity){
        return roleOperatePermsService.update(entity);
    }

    @PostMapping("/rop")
    @OperateLog(module="角色操作权限管理",type = "POST",desc = "添加系统角色操作权限信息")
    public AjaxResultPlus add(@RequestBody RolePermsReq entity){
        System.out.println(entity.getMatchMethod());
        return roleOperatePermsService.add(entity);
    }


    @Deprecated
//    @PutMapping("/rop")
    @OperateLog(module="角色操作权限管理",type = "PUT",desc = "修改系统角色操作权限信息")
    public AjaxResultPlus update(@RequestBody RolePermsReq entity){
        return roleOperatePermsService.update(entity);
    }

    @DeleteMapping("/rop")
    @OperateLog(module="角色操作权限管理",type = "DELETE",desc = "删除系统角色操作权限")
    public AjaxResultPlus delete(@RequestBody RequestList ids){
        return roleOperatePermsService.delete(ids);
    }
}
